package grailserrors

/**
 * Created by IntelliJ IDEA.
 * User: Zach
 * Date: 2/13/12
 * Time: 8:39 PM
 * To change this template use File | Settings | File Templates.
 */
class ErrorCodes {
    public static String NULLABLE = "nullable"
    public static String TOO_BIG = "size.toobig"
    public static String TOO_SMALL = "size.toosmall"
    public static String MIN_NOT_MET = "min.notmet"
    public static String BLANK = "blank"
    public static String MATCHES_INVALID = "matches.invalid"
    public static String VALIDATOR_INVALID = "validator.invalid"
    public static String EMAIL_INVALID = "email.invalid"

    public static Boolean CheckErrorCode(def obj, String property, String ErrorCode, Boolean printCode=false) {
        if (printCode) {println "$property error code: ${obj.errors[property]?.code}"}
        return obj.errors[property].code == ErrorCode
    }
}
